from rest_framework import serializers
from house import models


class House_city_Serializer(serializers.ModelSerializer):
    class Meta:
        model = models.House_city
        fields = '__all__'


class House_Serializer(serializers.ModelSerializer):
    # 使用House_city_Serializer来序列化city字段关联的House_city对象
    city = House_city_Serializer()
    # 同样使用House_city_Serializer来序列化city_pid字段关联的House_city对象
    city_pid = House_city_Serializer()

    class Meta:
        model = models.House
        fields = '__all__'


class User_record(serializers.ModelSerializer):
    class Meta:
        model = models.User_record
        fields = '__all__'
